package danZhouSai.game461;

//Q1. 三段式数组 I
public class Q461_1 {
    public static void main(String[] args) {
        int[] arr = new int[]{8,6,3,5};
        System.out.println(new Solution_461_Q1().isTrionic(arr));
    }
}

class Solution_461_Q1 {
    public boolean isTrionic(int[] nums) {
        if(nums.length < 4) return false;
        int p = -1;
        int q = -1;
        for(int i=0;i<nums.length - 1;i++){
            if(nums[i] == nums[i + 1])  return false;
            if((nums[i] > nums[i + 1]) && p == -1){
                p = i;
            }
            if((nums[i] < nums[i + 1]) && p != -1 && q == -1){
                q = i;
            }
            if(p != -1 && q != -1 && (nums[i] > nums[i + 1])){
                return false;
            }
        }
        return p != -1 && p != 0 && q != -1;
    }
}
